"use strict";

const __color__ = function(color, txt) {
  return `\x1b[${color}m${txt}\x1b[0m`;
};

/**
 * return `Bright`(高亮) color text
 * @param {string} txt  to be colored text.
 * @returns {string} colored text.
 */
const bright = function(txt) {
  return __color__(1, txt);
};

/**
 * return `Dim`(暗) color text
 * @param {string} txt  to be colored text.
 * @returns {string} colored text.
 */
const dim = function(txt) {
  return __color__(2, txt);
};

/**
 * return `Italic`(下划线) color text
 * @param {string} txt  to be colored text.
 * @returns {string} colored text.
 */
const italic = function(txt) {
  return __color__(3, txt);
};

/**
 * return `Underscore`(下划线) color text
 * @param {string} txt  to be colored text.
 * @returns {string} colored text.
 */
const underscore = function(txt) {
  return __color__(4, txt);
};

/**
 * return `Blink`(闪烁) color text
 * @param {string} txt  to be colored text.
 * @returns {string} colored text.
 */
const blink = function(txt) {
  return __color__(5, txt);
};

/**
 * return `Rapid blink`(极速闪烁) color text. 
 * MS-DOS ANSI.SYS, 150+ per minute; **not widely supported**.
 * @param {string} txt  to be colored text.
 * @returns {string} colored text.
 */
const blinkRapid = function(txt) {
  return __color__(6, txt);
};

/**
 * return `Reverse`(反转) color text
 * @param {string} txt  to be colored text.
 * @returns {string} colored text.
 */
const reverse = function(txt) {
  return __color__(7, txt);
};

/**
 * return `Hidden`(隐藏) color text
 * @param {string} txt  to be colored text.
 * @returns {string} colored text.
 */
const hidden = function(txt) {
  return __color__(8, txt);
};

/**
 * return `Cross-out`(删除线) color text
 * @param {string} txt  to be colored text.
 * @returns {string} colored text.
 */
const crossOut = function(txt) {
  return __color__(9, txt);
};

module.exports = {
  __color__,
  bright, dim, italic, underscore, blink, blinkRapid,
  reverse, hidden, crossOut
}; 

